<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no" />
	<title>消息</title>
	<link rel="stylesheet" type="text/css" href="../c/aui.css" />
	<style media="screen">
		.xiaoxi-list,
		.xiaoxi-list ul {
			background: none;
			color: #fff;
			border: 0;
		}

		.xiaoxi-list {
			border-top: 1px solid #222;
		}

		.xiaoxi-list .aui-list .aui-list-item {
			border-bottom: 0;
			background: none;
			padding-top: 0.5rem;
			padding-bottom: 0.5rem;
		}

		.xiaoxi-list .aui-list-item-media {
			width: 3.5rem;
		}

		.xiaoxi-list .user {
			font-size: 0.75rem;
			color: #fff;
			opacity: 0.9;
			margin-bottom: 0.2rem;
		}

		.xiaoxi-list .text {
			font-size: 0.65rem;
			color: #999;
			position: relative;
		}

		.xiaoxi-list .time {
			color: #777;
			font-size: 0.65rem;
			padding-top: 0.5rem;
		}

		.sx-btn {
			position: absolute;
			top: 1.65rem;
			right: 0.75rem;
			border-radius: 0.15rem;
			padding: 0.35rem 0rem;
			font-size: 0.65rem;
			width: 3rem;
			text-align: center;
			color: #999;
			background: #393B44;
		}

		.xiaoxi-list .text,
		.xiaoxi-list .user {
			margin-right: 4rem;
		}

		.sx-btn img {
			vertical-align: middle;
			width: 0.75rem;
			margin: 0 auto;
			text-align: center;
			display: inline-block;
			margin-right: 0.05rem;
		}

		.gz {
			background: #FF2C55 !important;
			color: #fff;
		}
	</style>
</head>

<body>
	<div class="aui-card-list xiaoxi-list ">
		<div class="aui-card-list-content">

			<script id="sx-list" type="text/x-dot-template">
				{{ for(var i=0,it=it.data; i
				< it.length; i++) { }} <li class="aui-list-item aui-list-item-middle">
					<div class="aui-media-list-item-inner">
						<div class="aui-list-item-media">
							<img tapmode onclick="_u({{= api.pageParam['index']==1 ? it[i].uid : it[i].gz_uid}})" src="{{= it[i].user.img ? _img(it[i].user.img,60,60) : '../i/touxiang.png' }}" class="aui-img-round">
						</div>
						<div class="aui-list-item-inner">
							<div class="user aui-ellipsis" tapmode onclick="_u({{= api.pageParam['index']==1 ? it[i].uid : it[i].gz_uid}})">
								{{= it[i].user.username }}
							</div>
							<div class="aui-ellipsis text" tapmode onclick="_u({{= api.pageParam['index']==1 ? it[i].uid : it[i].gz_uid}})">
								{{= it[i].user.qianming }}
							</div>
							<div class="time" tapmode onclick="_u({{= api.pageParam['index']==1 ? it[i].uid : it[i].gz_uid}})">{{= it[i].time }}</div>
							{{? it[i].member_guanzhu}}
							<em class="sx-btn" id="guanzhu_{{= api.pageParam['index']==1 ? it[i].uid : it[i].gz_uid}}" tapmode onclick="guanzhu_s({{= api.pageParam['index']==1 ? it[i].uid : it[i].gz_uid}})">已关注</em> {{??}}
							<em class="sx-btn gz" id="guanzhu_{{= api.pageParam['index']==1 ? it[i].uid : it[i].gz_uid}}" tapmode onclick="guanzhu_s({{= api.pageParam['index']==1 ? it[i].uid : it[i].gz_uid}})"><img src="../i/member_user_gz.png" />关注</em> {{?}}
						</div>
					</div>
					</li>
					{{ } }}
			</script>

			<ul class="aui-list aui-media-list" id="sx-view">
				<div id="loadingdi_huifu"><img src="../i/footer_progress.png" /></div>
			</ul>
		</div>
	</div>

</body>
<script type="text/javascript" src="../j/api.js"></script>

<script type="text/javascript">
	var uid = 0,
		url = '';
	apiready = function() {
		_user = _getPrefs('_user');
if(adName){
	_init_ad();
	ad = api.require(adName);
}

			uid = api.pageParam['uid'] ? api.pageParam['uid'] : _user.id;
			if (api.pageParam['index'] == 0) {
				url = 'member/guanzhu_list/uid/' + uid;
			} else {
				url = 'member/fensi/uid/' + uid;
			}
			if (!uid) {
				return _alert('uid错误', function(ret, err) {
					_close();
				})
			}
			_shangla(function(ret, err) {
					_list({
						url: url,
						loading: 1
					});
					banner();
				})
				// 监听滚动
			api.addEventListener({
				name: 'scrolltobottom',
				extra: {
					threshold: threshold //设置距离底部多少距离时触发，默认值为0，数字类型
				}
			}, function(ret, err) {
				if (heigutgao == 1) { // heigutgao=1开启执行 0停止执行   防止连续滚动，等加载数据之后在进行滚动。
					pagenum += 1
					_list({
						url: url,
						page: pagenum
					});
					banner();
				}
			});
		}
		// 关注状态
	function guanzhu_cls(type, uid) {
		banner();
		var _this = $('#guanzhu_' + uid);
		if (!type) {
			_this.removeClass('gz');
			_this.html('已关注');
		} else {
			_this.addClass('gz');
			_this.html('关注');
		}
	}

	// 关注/取消用户
	var _guanzhu_ajax = false;

	function guanzhu_s(uid) {
		banner();
		if (!uid) {
			return _msg('uid不能为空');
		}
		var _this = $('#guanzhu_' + uid);
		if (!_getPrefs('_user')) {
			return _login();
		}
		if (uid == _user.id) {
			return _msg('不能关注自己1');
		}
		if (_guanzhu_ajax) {
			return _msg('操作太快了');
		}
		_guanzhu_ajax = true;
		if (_this.hasClass('gz')) {
			// 取消用户
			_zhen();
			guanzhu_cls('', uid);
		} else {
			// 关注用户
			guanzhu_cls(1, uid);
		}
		_ajax('member/guanzhu', function(ret, err) {
			if (ret) {
				console.log(JSON.stringify(ret));
			} else {
				_alert(JSON.stringify(err))
			}
			_guanzhu_ajax = false;
		}, {
			gz_uid: uid
		})
	}
</script>

</html>
